package client.ftp;

/**
 * This is the super class for all types of file transfers.
 * it holds all general information for file transfer,
 * like username, host name, port number etc.
 * @author Robert Gutke
 */
public class FileTransfer {
    protected String hostname;
    protected String username;
    protected String password;
    protected int port;
    
    /**
     * The sole constructor for this class 
     * @param hostname the address (domain or IP) of the server
     * @param username the username of the ftp account
     * @param password the password of the ftp account
     * @param port the port number to which to connect to 
     */
    public FileTransfer(String hostname, String username, String password, int port) {
        this.hostname = hostname;
        this.username = username;
        this.password = password;
        this.port = port;
    }

    /**
     * Returns the host name
     * @return the host name as a string
     */
    public String getHostname() {
        return hostname;
    }

    /**
     * sets the host name of the server
     * @param hostname the address (domain or IP) of the server
     */
    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    /**
     * Returns the username
     * @return the username as a string
     */
    public String getUsername() {
        return username;
    }

    /**
     * sets the username
     * @param username the user name of the ftp account
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Returns the password
     * @return the password as a string
     */
    public String getPassword() {
        return password;
    }

    /**
     * sets the password
     * @param password the password of the ftp account
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Returns the port number
     * @return the port number as an integer
     */
    public int getPort() {
        return port;
    }

     /**
     * sets the port number
     * @param port the port number to connect to
     */
    public void setPort(int port) {
        this.port = port;
    }
    
    /**
     * Outputs a general message to the console
     * @param s The string to output
     */
    protected void printMessage(String s) {
        System.out.println(s);
    }

    /**
     * Outputs an error message to the console.
     * @param e The corresponding error exception
     */
    protected void printError(Exception e) {
        System.err.println(e.getMessage());
    }
    
    /**
     * Outputs an error message to the console.
     * @param e The corresponding error exception
     */
    protected void printError(String s) {
        System.err.println(s);
    }
    
    /**
     * Outputs a string and an error message to the console.
     * @param e The corresponding error exception plus an additional preceeding string
     */
    protected void printError(String s, Exception e) {
        System.err.println(s+e.getMessage());
    }
}
